package com.ybt.heartratem.moudle.main;

import android.os.Bundle;

import androidx.lifecycle.ViewModelProviders;

import com.bumptech.glide.Glide;
import com.ybt.heartratem.R;
import com.ybt.heartratem.common.app.AppViewModelFactory;
import com.ybt.heartratem.common.app.MyApplication;
import com.ybt.heartratem.databinding.ActivityShowBigPicBinding;
import com.ybt.heartratem.moudle.MainVM;

import java.io.File;

import me.goldze.mvvmhabit.base.BaseActivity;
import me.tatarka.bindingcollectionadapter2.BR;

public class ShowBigPicActivity extends BaseActivity<ActivityShowBigPicBinding, MainVM> {
    String filePath;
    int type;

    @Override
    public MainVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(MyApplication.getInstance());
        return ViewModelProviders.of(this, factory).get(MainVM.class);
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_show_big_pic;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        filePath = getIntent().getStringExtra("filePath");
        type = getIntent().getIntExtra("type", 0);
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
        if (type == 1) {
            Glide.with(this).load(new File(filePath)).into(binding.showBigIv);
        } else {
            Glide.with(this).load(filePath).into(binding.showBigIv);
        }
        binding.backIv.setOnClickListener(view -> {
            finish();
        });
    }
}